%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/single-table-items-and-children"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[74]<br />ᐳ: Access[9], Access[10], Object[11]<br />2: PgSelect[8]<br />ᐳ: Access[75]<br />3: Connection[12]<br />4: ConnectionItems[14]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 75, 14<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 75<br /><br />ROOT __Item{3}ᐸ14ᐳ[17]<br />1: <br />ᐳ: 18, 76, 19, 21, 22, 77<br />2: PgSelectRows[53]"):::bucket
    Bucket4("Bucket 4 (polymorphic)<br />__typename: Lambda[22]<br />Deps: 22, 53, 18, 19, 21"):::bucket
    Bucket5("Bucket 5 (listItem)<br /><br />ROOT __Item{5}ᐸ53ᐳ[54]"):::bucket
    Bucket6("Bucket 6 (polymorphic)<br />__typename: Lambda[63]<br />Deps: 63, 55, 60, 69"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸsingle_table_itemsᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply74["PgSelectInlineApply[74∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply74 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    ConnectionItems14[["ConnectionItems[14∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems14
    Access75{{"Access[75∈0] ➊<br />ᐸ8.m.subqueryDetailsFor33ᐳ"}}:::plan
    PgSelect8 --> Access75
    List76{{"List[76∈3]<br />ᐸ75,17ᐳ"}}:::plan
    __Item17[/"__Item[17∈3]<br />ᐸ14ᐳ"\]:::itemplan
    Access75 & __Item17 --> List76
    ConnectionItems14 ==> __Item17
    PgSelectSingle18{{"PgSelectSingle[18∈3]<br />ᐸsingle_table_itemsᐳ"}}:::plan
    __Item17 --> PgSelectSingle18
    PgClassExpression19{{"PgClassExpression[19∈3]<br />ᐸ__single_t...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle18 --> PgClassExpression19
    PgClassExpression21{{"PgClassExpression[21∈3]<br />ᐸ__single_t...s__.”type”ᐳ"}}:::plan
    PgSelectSingle18 --> PgClassExpression21
    Lambda22{{"Lambda[22∈3]<br />ᐸSingleTableItem_typeNameFromTypeᐳ"}}:::plan
    PgClassExpression21 --> Lambda22
    PgSelectRows53[["PgSelectRows[53∈3]"]]:::plan
    Lambda77{{"Lambda[77∈3]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda77 --> PgSelectRows53
    List76 --> Lambda77
    __Item54[/"__Item[54∈5]<br />ᐸ53ᐳ<br />ᐳSingleTableTopic<br />ᐳSingleTablePost<br />ᐳSingleTableDivider<br />ᐳSingleTableChecklist<br />ᐳSingleTableChecklistItem"\]:::itemplan
    PgSelectRows53 ==> __Item54
    PgSelectSingle55{{"PgSelectSingle[55∈5]^<br />ᐸsingle_table_itemsᐳ"}}:::plan
    __Item54 --> PgSelectSingle55
    PgClassExpression60{{"PgClassExpression[60∈5]^<br />ᐸ__single_t...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle55 --> PgClassExpression60
    PgClassExpression62{{"PgClassExpression[62∈5]^<br />ᐸ__single_t...s__.”type”ᐳ"}}:::plan
    PgSelectSingle55 --> PgClassExpression62
    Lambda63{{"Lambda[63∈5]^<br />ᐸSingleTableItem_typeNameFromTypeᐳ"}}:::plan
    PgClassExpression62 --> Lambda63
    PgClassExpression69{{"PgClassExpression[69∈5]^<br />ᐸ__single_t...”position”ᐳ"}}:::plan
    PgClassExpression60 o--o PgClassExpression69

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,ConnectionItems14,PgSelectInlineApply74,Access75 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item17,PgSelectSingle18,PgClassExpression19,PgClassExpression21,Lambda22,PgSelectRows53,List76,Lambda77 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item54,PgSelectSingle55,PgClassExpression60,PgClassExpression62,Lambda63,PgClassExpression69 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6 bucket6

